﻿using System.IO;
using QuantBox.XApi;
using SmartQuant;

namespace QuantBox
{
    public class DepthMarketTradeStreamer : ObjectStreamer
    {
        public DepthMarketTradeStreamer()
        {
            typeId = 220;
            type = typeof(DepthMarketDataField);
        }

        public override byte GetVersion(object obj)
        {
            return 1;
        }

        public override void Write(BinaryWriter writer, object obj)
        {
            var field = (DepthMarketDataField)obj;
            writer.Write(field.Turnover);
            writer.Write(field.OpenInterest);
        }

        public override object Read(BinaryReader reader, byte version)
        {
            var field = new DepthMarketDataField();
            field.Turnover = reader.ReadDouble();
            field.OpenInterest = reader.ReadDouble();
            return field;
        }
    }
}